import 'package:flutter/material.dart';
import 'model/ScoresModel.dart';
//灰色字体统一样式
TextStyle _greyTextStyle = new TextStyle(color: Colors.grey, fontSize: 16);
//黑色字体统一样式
TextStyle _blackTextStyle = new TextStyle(color: Colors.black, fontSize: 18);
Widget ScoreWidget(Scores scores) {
  return Column(
    children: <Widget>[
      SizedBox(
        height: 15,
      ),
      _SubmitTime(scores),
      SizedBox(
        height: 5,
      ),
      Padding(
        padding: EdgeInsets.only(left: 20),
        child: Divider(
          color: Colors.grey,
        ),
      ),
      SizedBox(
        height: 10,
      ),
      _ScoresImg(scores),
      SizedBox(
        height: 20,
      ),
      _ScoresInfo(scores),
      SizedBox(
        height: 30,
      ),
      Padding(
        padding: EdgeInsets.only(left: 20),
        child: Divider(
          color: Colors.grey,
        ),
      ),
    ],
  );
}


/*
 * @auther YuanShuai
 * @created at 2019/2/19 15:38
 * @desc 顶部交卷时间
 */
Widget _SubmitTime(Scores scores) {
  return Padding(
    padding: EdgeInsets.only(left: 20),
    child: Row(
      mainAxisAlignment: MainAxisAlignment.start,
      children: <Widget>[
        Text(
          '交卷时间:',
          style: _greyTextStyle,
        ),
        Text(
          '${scores.submitTime}',
          style: _greyTextStyle,
        ),
      ],
    ),
  );
}
/*
 * @auther YuanShuai
 * @created at 2019/2/19 15:38
 * @desc 得分
 */
Widget _ScoresImg(Scores scores) {
  return Stack(
    alignment: const FractionalOffset(0.5, 0.42),
    children: <Widget>[
      Image.asset(
        'images/qbank_bg.png',
        height: 180,
        width: 180,
      ),
      Row(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.end,
        children: <Widget>[
          Text(
            '${scores.score}',
            style: TextStyle(fontSize: 36),
          ),
          Padding(
            padding: EdgeInsets.only(bottom: 7),
            child: Text(
              '分',
              style: TextStyle(fontSize: 16),
            ),
          )
        ],
      ),
      Positioned(top: 128, child: Text('得分', style: TextStyle(fontSize: 16))),
    ],
  );
}
/*
 * @auther YuanShuai
 * @created at 2019/2/19 15:38
 * @desc 详情
 */
Widget _ScoresInfo(Scores scores) {
  return Container(
    child: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Column(
          crossAxisAlignment: CrossAxisAlignment.end,
          children: <Widget>[
            Container(
              margin: EdgeInsets.only(bottom: 10),
              child: Row(
                children: <Widget>[
                  Text(
                    '考试用时',
                    style: _greyTextStyle,
                  ),
                  Container(
                    padding: EdgeInsets.only(left: 5),
                    child: Text(
                      '${scores.examTime}',
                      style: _blackTextStyle,
                    ),
                  ),
                  Text(
                    '分钟',
                    style: _greyTextStyle,
                  ),
                ],
              ),
            ),
            Row(
              children: <Widget>[
                Text(
                  '全站排名',
                  style: _greyTextStyle,
                ),
                Container(
                  padding: EdgeInsets.only(left: 5),
                  child: Text(
                    '${scores.ranking}',
                    style: _blackTextStyle,
                  ),
                ),
                Text(
                  '名',
                  style: _greyTextStyle,
                ),
              ],
            )
          ],
        ),
        Container(
          margin: EdgeInsets.only(left: 25, right: 25),
          height: 40.0,
          decoration: BoxDecoration(
            border: Border(
              right: BorderSide(
                color: Colors.grey,
                width: 0.5,
              ),
            ),
          ),
        ),
        Column(
          crossAxisAlignment: CrossAxisAlignment.end,
          children: <Widget>[
            Container(
              margin: EdgeInsets.only(bottom: 10),
              child: Row(
                children: <Widget>[
                  Text(
                    '全站最高分',
                    style: _greyTextStyle,
                  ),
                  Container(
                    padding: EdgeInsets.only(left: 5),
                    child: Text(
                      '${scores.highScore}',
                      style: _blackTextStyle,
                    ),
                  ),
                  Text(
                    '分',
                    style: _greyTextStyle,
                  ),
                ],
              ),
            ),
            Row(
              children: <Widget>[
                Text(
                  '全站平均得分',
                  style: _greyTextStyle,
                ),
                Container(
                  padding: EdgeInsets.only(left: 5),
                  child: Text(
                    '${scores.average}',
                    style: _blackTextStyle,
                  ),
                ),
                Text(
                  '分',
                  style: _greyTextStyle,
                ),
              ],
            )
          ],
        ),
      ],
    ),
  );
}
